<?php

/**
 * This is the model class for table "{{album}}".
 *
 * The followings are the available columns in table '{{album}}':
 * @property integer $album_id
 * @property integer $category_id
 * @property string $title
 * @property string $create_time
 * @property integer $update_time
 * @property integer $user_id
 * @property string $cover
 * @property integer $total_share
 * @property integer $total_favorite
 * @property integer $is_system
 * @property integer $is_show
 * @property integer $top
 */
class Album extends CActiveRecord
{
	/**
	 * Returns the static model of the specified AR class.
	 * @param string $className active record class name.
	 * @return Album the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}

	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return '{{album}}';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('category_id, title, create_time, user_id', 'required'),
			array('category_id, update_time, user_id, total_share, total_favorite, is_system, is_show, top', 'numerical', 'integerOnly'=>true),
			array('title, cover', 'length', 'max'=>255),
			// The following rule is used by search().
			// Please remove those attributes that should not be searched.
			array('album_id, category_id, title, create_time, update_time, user_id, cover, total_share, total_favorite, is_system, is_show, top', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'album_id' => 'Album',
			'category_id' => 'Category',
			'title' => 'Title',
			'create_time' => 'Create Time',
			'update_time' => 'Update Time',
			'user_id' => 'User',
			'cover' => 'Cover',
			'total_share' => 'Total Share',
			'total_favorite' => 'Total Favorite',
			'is_system' => 'Is System',
			'is_show' => 'Is Show',
			'top' => 'Top',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 * @return CActiveDataProvider the data provider that can return the models based on the search/filter conditions.
	 */
	public function search()
	{
		// Warning: Please modify the following code to remove attributes that
		// should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('album_id',$this->album_id);
		$criteria->compare('category_id',$this->category_id);
		$criteria->compare('title',$this->title,true);
		$criteria->compare('create_time',$this->create_time,true);
		$criteria->compare('update_time',$this->update_time);
		$criteria->compare('user_id',$this->user_id);
		$criteria->compare('cover',$this->cover,true);
		$criteria->compare('total_share',$this->total_share);
		$criteria->compare('total_favorite',$this->total_favorite);
		$criteria->compare('is_system',$this->is_system);
		$criteria->compare('is_show',$this->is_show);
		$criteria->compare('top',$this->top);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}
}